﻿
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
namespace XRPlayer
{

    public class XRPlayerControlLite : MonoBehaviour
    {
        public GameObject m_VideoCanvas;

        public VideoPlayer videoPlayer;
        public AudioSource audioPlayer;
        [HideInInspector]
        public float m_WaitForSecond = 1f;
        [HideInInspector]
        public bool m_Loop = false;

        private void Start()
        {
            //初始化，是否等待,是否循环
            Init();

        }
        private void Init()
        {
            WaitForTime();
            SetLoop(m_Loop);
        }
        public void OnPlay()
        {
            videoPlayer.Play();
        }

        public void OnPause()
        {
            videoPlayer.Pause();
        }
        public void SetLoop(bool isLoop)
        {
            videoPlayer.isLooping = isLoop;
        }
        public void WaitForTime()
        {
            StartCoroutine(WaitPlayTime(m_WaitForSecond));
        }

        private IEnumerator WaitPlayTime(float m_WaitForSecond)
        {
            yield return new WaitForSeconds(m_WaitForSecond);
            OnPlay();
        }

        public void OnReview()
        {
            videoPlayer.Stop();
            videoPlayer.Play();
        }

        public void OnNext()
        {
        }

        public void OnBack()
        {
        }



        public void OnSoundOff()
        {
            audioPlayer.mute = true;
        }
        public void OnSoundOn()
        {
            audioPlayer.mute = false;
        }


        public void OnPlaySpeedChange()
        {
            //VideoPlayer.playbackSpeed
        }
        /// <summary>
        /// Get the video
        /// </summary>
        public void GetVideoClip()
        {

        }
    }
}